package com.jy.rhin.facade.infra.controller.document;

import com.jy.framework.base.entity.Page;
import com.jy.framework.base.entity.Result;
import com.jy.rhin.infra.repo.document.content.query.DocumentContentQueryHandler;
import com.jy.rhin.infra.repo.document.submission.query.DocumentSubmissionQueryHandler;
import com.jy.rhin.infra.repo.document.template.query.DocumentTemplateQueryHandler;
import com.jy.rhin.sdk.dto.document.DocumentContentDto;
import com.jy.rhin.sdk.dto.document.query.DocumentManagerReqDto;
import com.jy.rhin.sdk.dto.document.query.DocumentManagerRespDto;
import com.jy.rhin.sdk.dto.document.query.DocumentValidationFileRespDto;
import com.jy.rhin.sdk.dto.document.query.GetContentDto;
import com.jy.rhin.sdk.dto.document.template.DocumentTemplateDto;
import com.jy.rhin.sdk.dto.document.template.QueryTemplateDto;
import com.jy.rhin.sdk.feign.client.DocumentQueryFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author dhl
 * @date 2022/6/16
 * @Description
 */
@RestController
@RequestMapping("/infra/documentQuery")
@Api(tags = "文档查询api")
public class DocumentQueryController implements DocumentQueryFeign {
    @Resource
    private DocumentContentQueryHandler documentContentQueryHandler;
    @Resource
    private DocumentSubmissionQueryHandler documentSubmissionQueryHandler;

    @Resource
    DocumentTemplateQueryHandler documentTemplateQueryHandler;

    @Override
    @ApiOperation("分页查询文档管理")
    @GetMapping("/getDocumentManagerPage")
    public Result<Page<DocumentManagerRespDto>> getDocumentManagerPage(DocumentManagerReqDto dto) {
        return Result.success(documentSubmissionQueryHandler.getDocumentManagerPage(dto));
    }

    @Override
    @ApiOperation("查询文档模板")
    @GetMapping("/queryTemplate")
    public Result<List<DocumentTemplateDto>> queryTemplate(QueryTemplateDto dto) {
        return Result.success(documentTemplateQueryHandler.queryTemplate(dto.getDocumentType()));
    }

    @Override
    @ApiOperation("获取文档内容")
    @GetMapping("/getContent")
    public Result<DocumentContentDto> getContent(GetContentDto dto) {
        return Result.success(documentContentQueryHandler.getContent(dto));
    }

    @Override
    public Result<Integer> getRuleNumByFileType(DocumentValidationFileRespDto documentValidationFileRespDto) {
        return null;
    }

}
